package com.example.mapper;

import com.example.model.vo.QueryOpenAreaVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @ClassName RegionMapper
* @author zhexueqi
* @since 2025/4/2    15:46
*/
public interface RegionMapper {

    @Insert("INSERT INTO region (region_id, region_code, region_name, parent_code, region_level, region_order, region_name_en, region_shortname, region_pinyin, longitude, latitude, status, create_time, update_time) " +
            "VALUES (#{regionId}, #{regionCode}, #{regionName}, #{parentCode}, #{regionLevel}, #{regionOrder}, #{regionNameEn}, #{regionShortname}, #{regionPinyin}, #{longitude}, #{latitude}, #{status}, #{createTime}, #{updateTime})")
    int insertRegion(QueryOpenAreaVO region);

    @Delete("DELETE FROM region WHERE region_id = #{regionId}")
    int deleteRegionById(Long regionId);

    @Update("UPDATE region SET region_code = #{regionCode}, region_name = #{regionName}, parent_code = #{parentCode}, region_level = #{regionLevel}, region_order = #{regionOrder}, region_name_en = #{regionNameEn}, region_shortname = #{regionShortname}, region_pinyin = #{regionPinyin}, longitude = #{longitude}, latitude = #{latitude}, status = #{status}, create_time = #{createTime}, update_time = #{updateTime} " +
            "WHERE region_id = #{regionId}")
    int updateRegion(QueryOpenAreaVO region);

    @Select("SELECT * FROM region WHERE region_id = #{regionId}")
    QueryOpenAreaVO selectRegionById(Long regionId);

    @Select("SELECT * FROM region")
    List<QueryOpenAreaVO> selectAllRegions();
}